#include<bits/stdc++.h>

using namespace std;
using oi = ostream_iterator<int>;
int main() {
	int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
	int n = sizeof(a) / sizeof(a[0]);
	do {
		int x = 100 * a[0] + a[1] * 10 + a[2];
		int y = 100 * a[3] + a[4] * 10 + a[5];
		int z = 100 * a[6] + a[7] * 10 + a[8];
		if(y == 2 * x && z == 3 * x) {
			copy(a, a + n, oi(cout, " "));
			cout << endl;
		}


	} while(next_permutation(a, a + n));
	return 0;
}
